<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>添加新闻</title>
		<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
		<script type="text/javascript" src="ckfinder/ckfinder.js"></script>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	</head>

	<body>
		添加新闻
		<br />
		<form action="">
			<textarea rows="30" cols="50" name="editor01">请输入.</textarea>
			<script type="text/javascript">
	var editor = CKEDITOR.replace('editor01', addUploadButton(this), {
		width : '1000'
	});

	function addUploadButton(editor) {

		CKEDITOR.on('dialogDefinition', function(ev) {

			var dialogName = ev.data.name;

			var dialogDefinition = ev.data.definition;

			if (dialogName == 'image') {

				var infoTab = dialogDefinition.getContents('info');

				infoTab.add( {

					type : 'button',

					id : 'upload_image',

					align : 'center',

					label : '上传',

					onClick : function(evt) {

						var thisDialog = this.getDialog();

						var txtUrlObj = thisDialog.getContentElement('info',
								'txtUrl');

						var txtUrlId = txtUrlObj.getInputElement().$.id;

						addUploadImage(txtUrlId);

					}

				}, 'browse');

			}

		});

	}
	
	function addUploadImage(theURLElementId){

           var uploadUrl = "admin/uploadsFiles.jsp"; //这是我自己的处理文件/图片上传的页面URL

           var imgUrl = window.showModalDialog(uploadUrl);

       //在upload结束后通过js代码window.returnValue=...可以将图片url返回给imgUrl变量。

       //更多window.showModalDialog的使用方法参考

           var urlObj = document.getElementById(theURLElementId);

           urlObj.value = imgUrl;

           urlObj.fireEvent("onchange"); //触发url文本框的onchange事件，以便预览图片

  }
</script>
			<br/>
			<input type="button" value="提交" />
		</form>
	</body>
</html>
